package infopreserve.main.mobile;

import java.util.ArrayList;

public class Item {
    public String Name;
    public int Size;
    public String comments;
    public String path;
    public String category;
    public ArrayList<Item> i;
    public Item(){
        super();
    }
    
    public Item(String name, int size, String path, String category, String comments, ArrayList<Item> i) {
        super();
        this.Name = name;
        this.Size = size;
        this.comments= comments;
        this.path=path;
        this.category= category;
        this.i = i;
    }
    
    public String getName(){
    	return Name;
    }
    
    public String getSize(){
    	int temp = Size;
    	int kb = 0;
    	int mb = 0;
    	int gb = 0;
    	while(temp >= 1024){
    		kb++;
    		temp -= 1024;
    		if(kb >= 1024){
    			mb++;
    			kb -= 1024;
    			if(mb >= 1024){
    				gb++;
    				mb -= 1024;
    			}
    		}
    	}
    	if(kb >= 1 && mb >= 1 && gb >= 1){
    		return Integer.toString(gb) + "." + Integer.toString(mb) + " GB";
    	}else if(kb >= 1 && mb >= 1 && gb <= 0){
    		return Integer.toString(mb) + "." + Integer.toString(kb) + " MB";
    	}else if(kb >= 1 && mb <= 0 && gb <= 0){
    		return Integer.toString(kb) + "." + Integer.toString(temp) + " KB";
    	}else
    	return Integer.toString(Size) + " bytes";
    }
    
    public String getPath(){
    	return path;
    }
    
    public String getCategory(){
    	return category;
    }
    
    public String getComments(){
    	return comments;
    }
    
    public void remove(){
    	i.remove(this);
    }
    
    public String getLoc(){
        String filename = "";
        for(int i = path.length()-1; i <= path.length()-1; i--){
        	try{
        	if(path.charAt(i) == '/')
        		filename = path.substring(0, i);
        	}
        	catch(Exception e){
        		break;
        		}
        		break;
        	}
        return filename;
    }
}
